/**
 * @author 黄波
 * 创建日期：2011Sep 1, 2011
 * TODO// N/A
 */
package com.platform.dev.action;

import java.io.PrintWriter;
import java.util.HashMap;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.platform.dev.bo.DevBo;

//删除权限
public class DelPowerAction extends DevSupport {

	private String id;//要删除的权限记录ID
	private String msg;	//返回信息
	private boolean success;	//返回是否成功标识
	
	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * @return the success
	 */
	public boolean isSuccess() {
		return success;
	}

	/**
	 * @param success the success to set
	 */
	public void setSuccess(boolean success) {
		this.success = success;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 *
	 */
	@Override
	public String execute() throws Exception {
		if(id != null && !id.equals("")) {
			//执行删除操作
			DevBo bo = new DevBo();
//			PowerType power = bo.getPower(id);
//			if(power == null) {
//				msg = "删除失败，无此记录！";
//			} else {
				if(bo.deletePower(id)) {
					msg = "删除成功！";
				} else {
					msg = "删除失败，数据库错误！";
				}
//			}
		} else {
			msg = "ID不能为空！";
		}

		success = true;
		HashMap map = new HashMap();
		map.put("msg", msg);
		map.put("success", success);
		JSONObject json = JSONObject.fromObject(map);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		out.println(json.toString());
		out.flush();
		out.close();
		return null;
	}

	
}
